package com.ucs.ui;

import android.app.ExpandableListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ExpandableListView;

public class SelectTableActivity extends ExpandableListActivity{
	public static final String TABLE_NAME="TABLE_NAME";
	public static final String TABLE_ID="TABLE_ID";
	private TableListAdaptor tla = new TableListAdaptor();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setListAdapter(tla); 
	}

	@Override
	public boolean onChildClick(ExpandableListView parent, View v,
			int groupPosition, int childPosition, long id) {

		char tableLetter = TableListAdaptor.tableLetters[groupPosition];
		int tableNumber = childPosition+1;
		Bundle bundle = new Bundle();
		bundle.putString(TABLE_NAME, ""+tableLetter+tableNumber);
		bundle.putInt(TABLE_ID, groupPosition*100+childPosition+1);
		Intent intent = new Intent();
		intent.putExtras(bundle);
		setResult(RESULT_OK, intent);
		finish();		
		return true;
	}
}
